import java.io.Serializable;

public class OrderItem implements Serializable {
    private Integer productId;
    private String productName;
    private Double price;
    private Integer quantity;

    public OrderItem() {}

    public OrderItem(Integer productId, String productName, Double price, Integer quantity) {
        this.productId = productId;
        this.productName = productName;
        this.price = price;
        this.quantity = quantity;
    }

    public Integer getProductId() { return productId; }
    public void setProductId(Integer productId) { this.productId = productId; }

    public String getProductName() { return productName; }
    public void setProductName(String productName) { this.productName = productName; }

    public Double getPrice() { return price; }
    public void setPrice(Double price) { this.price = price; }

    public Integer getQuantity() { return quantity; }
    public void setQuantity(Integer quantity) { this.quantity = quantity; }

    public Double getSubtotal() {
        return price * quantity;
    }

    @Override
    public String toString() {
        return String.format("商品ID: %d, 名称: %s, 单价: %.2f, 数量: %d, 小计: %.2f",
                productId, productName, price, quantity, getSubtotal());
    }
}